import request from '@/utils/request'

const URL = 'op/order'

// 新增订单
export function addOrder(data) {
  return request({
    url: URL + '/add',
    method: 'post',
    data: data
  })
}

// 删除订单
export function delOrder(data) {
  return request({
    url: URL + '/delete',
    method: 'post',
    data: {
      orderId: data
    }
  })
}

// 根据id取消订单
export function cancelOrder(id) {
  return request({
    url: URL + '/cancel',
    method: 'post',
    data: {
      orderId: id
    }
  })
}

// 更新订单
export function updateOrder(data) {
  return request({
    url: URL + '/update',
    method: 'post',
    data: data
  })
}

// 支付指定订单id的订单
export function payOrder(id) {
  return request({
    url: URL + '/pay',
    method: 'post',
    data: {
      orderId: id
    }
  })
}

// 根据用户id找到所有订单
export function getOrderByUserId(data) {
  return request({
    url: URL + '/user/' + data,
    method: 'post',
    data: {
    }
  })
}

// 根据名字和手机号找到指定的订单
export function getOrderByNameAndPhone(data) {
  return request({
    url: URL + '/withNameAndPhone',
    method: 'get',
    data: data
  })
}

// 根据id找到指定的订单
export function getOrderById(data) {
  return request({
    url: URL + '/' + data,
    method: 'get',
    data: {

    }
  })
}

// 得到所有订单
export function getAllOrder() {
  return request({
    url: URL,
    method: 'get'
  })
}

// 得到订单数量
export function getOrderCount() {
  return request({
    url: URL + '/count',
    method: 'get'
  })
}
